#include "SceneManager.h"
#include "Framework.h"
#include "../UserInfoLoader.h"
#include "../MainMenuLoader.h"
#include "../HomeSceneContentLoader.h"
#include "HomeSceneLoader.h"
#include "../TaskDescLoader.h"
#include "../TaskListLoader.h"
#include "DungeonsListSceneLoader.h"
#include "FightSucceedSceneLoader.h"
#include "FightFailedSceneLoader.h"
#include "PacketScene.h"
#include "PacketSceneLoader.h"
#include "EquipMergeSceneLoader.h"
#include "../EquipIconLoader.h"
#include "../MainToolsLoader.h"
#include "ChallengeSceneLoader.h"
#include "../ChallengeItemLoader.h"
#include "../ChallengeEnemyItemLoader.h"
#include "../PlayerDetailContentLoader.h"
#include "PlayerDetailSceneLoader.h"
#include "DungeonsSceneLoader.h"
#include "../EquipDetailLoader.h"
#include "SnatchSceneLoader.h"
#include "../SnatchFragmentIconLoader.h"

SceneManager::SceneManager()
{
    
}

SceneManager::~SceneManager()
{
    
}


State* SceneManager::getState( const string& name )
{
	if (name == "HomeScene")
	{
		RegisterLoader("UserInfo", UserInfoLoader::loader());
		RegisterLoader("MainMenu", MainMenuLoader::loader());
		RegisterLoader("MainTools", MainToolsLoader::loader());
		RegisterLoader("HomeSceneContent", HomeSceneContentLoader::loader());
		RegisterLoader("HomeScene", HomeSceneLoader::loader());
	}
	else if(name == "DungeonsScene")
	{
		RegisterLoader("UserInfo", UserInfoLoader::loader());
		RegisterLoader("MainMenu", MainMenuLoader::loader());
		RegisterLoader("TaskDesc", TaskDescLoader::loader());
		RegisterLoader("TaskList", TaskListLoader::loader());
		RegisterLoader("DungeonsScene", DungeonsSceneLoader::loader());
	}
	else if(name == "DungeonsListScene")
	{
		RegisterLoader("UserInfo", UserInfoLoader::loader());
		RegisterLoader("MainMenu", MainMenuLoader::loader());
		RegisterLoader("TaskDesc", TaskDescLoader::loader());
		RegisterLoader("TaskList", TaskListLoader::loader());
		RegisterLoader("DungeonsListScene", DungeonsListSceneLoader::loader());
	}
	else if(name == "FightSucceedScene")
	{
		RegisterLoader("MainMenu", MainMenuLoader::loader());
		RegisterLoader("EquipDetail", EquipDetailLoader::loader());
		RegisterLoader("FightSucceedScene", FightSucceedSceneLoader::loader());
	}
	else if(name == "FightFailedScene")
	{
		RegisterLoader("MainMenu", MainMenuLoader::loader());
		RegisterLoader("FightFailedScene", FightFailedSceneLoader::loader());
	}
	else if(name == "PacketScene")
	{
		RegisterLoader("EquipIcon", EquipIconLoader::loader());
		RegisterLoader("MainMenu", MainMenuLoader::loader());
		RegisterLoader("PacketScene", PacketSceneLoader::loader());
	}
	else if (name == "EquipMergeScene")
	{
		RegisterLoader("EquipMergeScene", EquipMergeSceneLoader::loader());
	}
	else if(name == "ChallengeScene")
	{
		RegisterLoader("ChallengeItem", ChallengeItemLoader::loader());
		RegisterLoader("ChallengeEnemyItem", ChallengeEnemyItemLoader::loader());
		RegisterLoader("ChallengeScene", ChallengeSceneLoader::loader());
	}
	else if(name == "PlayerDetailScene")
	{
		RegisterLoader("PlayerDetailContent", PlayerDetailContentLoader::loader());
		RegisterLoader("PlayerDetailScene", PlayerDetailSceneLoader::loader());
	}
	else if(name == "SnatchScene")
	{
		RegisterLoader("SnatchFragmentIcon", SnatchFragmentIconLoader::loader());
		RegisterLoader("SnatchScene", SnatchSceneLoader::loader());
	}
	
	std::string stateName = std::string(name);
	stateName.append(".ccbi");
	State* state = (State*)ReadNode(stateName.c_str(), Framework::getSingletonPtr()->stateLayer);
	return state;
}

